package avicit.bdp.dds.server.filter;

import org.springframework.core.type.ClassMetadata;
import org.springframework.core.type.classreading.MetadataReader;
import org.springframework.core.type.classreading.MetadataReaderFactory;
import org.springframework.core.type.filter.TypeFilter;

import java.io.IOException;

/**
 * @author mayi
 * 自定义spring注解过滤器
 */
public class BdpSpringTypeFilter implements TypeFilter {
    /**
     * @param metadataReader:读取到的正在扫描的类的信息
     * @param metadataReaderFactory:可以获取到的其他任何类的信息
     */
    @Override
    public boolean match(MetadataReader metadataReader, MetadataReaderFactory metadataReaderFactory) throws IOException {
        //获取当前正在扫描的类的信息
        ClassMetadata classMetadata = metadataReader.getClassMetadata();
        //获取当前类的类名
        String className = classMetadata.getClassName();
        if (className.contains("bdp.dds.apc") || className.contains("bdp.dds.api.job") ||
                className.contains("DataStatService") || className.contains("bdp.dds.api.controller")) {
            return true;
        }

        return false;
    }
}
